package com.woniuxy.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
@Configuration
public class Swagger2 {
    @Bean
    public Docket createRestApi() {
        //API构建器
        ApiInfoBuilder apiBuilder = new ApiInfoBuilder();
        //设置API的相关信息
        apiBuilder.title("蜗牛OA系统");
        apiBuilder.description("只为成就更好的你");
        apiBuilder.contact(new Contact("蜗牛学院","www.woniuxy.com","dengqiang@woniuxy.com"));
        apiBuilder.version("1.0");
        //构建API对象
        ApiInfo api = apiBuilder.build();
        //构建API清单 用于说明那些接口需要生成API文档
        Docket docket = new Docket(DocumentationType.SWAGGER_2).apiInfo(api);
        //定义接口（控制层）所在的包
        docket.select().apis(RequestHandlerSelectors.basePackage("com.woniuxy.controller")).paths(PathSelectors.any()).build();
        return docket;
    }
}
